package com.studyv3.test.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.studyv3.test.domain.Stock;
import com.studyv3.test.mapper.ProductsMapper;
import com.studyv3.test.mapper.StockMapper;
import com.studyv3.test.service.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * lb_库存表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-05-06
 */
@Service
public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements IStockService {

@Autowired
StockMapper stockMapper;
@Autowired
    ProductsMapper productsMapper;

    @Override
    public List<Stock> selectStock(Stock stock) {

        return stockMapper.stockList(stock);
    }

    @Override
    public List<Stock> selectStockNoBatch(Stock stock) {
        List<Stock>list= stockMapper.listwithnobatch(stock);
        for(Stock item:list){
            if (item.getProductsNum()<=item.getWarnNum() ){
                item.setWarn(1);
            }else{
                item.setWarn(0);
            }
        }
        return list;
    }
}
